package demo3;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int len = scan.nextInt() ;
        for(int i= 0 ; i <len ; i ++){
            int num = scan.nextInt() ;
            System.out.println(check(num));
        }
    }

    private static String check(int num){
        int index = 0 ;
        int tmp = num ;
        boolean flg = false ;
        while(tmp > 0){
            if(tmp % 2 == 0){
                flg = true ;
                break ;
            }
            index ++ ;
            tmp /=10 ;
        }
        if(flg == false){
            return "-1";
        }
        int tmp2 = tmp %10 ;
        int end = num % 10 ;
        StringBuilder strbu = new StringBuilder() ;
        for(int i = 0 ; num > 0 ; i ++,num/=10){
            if(i == 0 ){
                strbu.append(tmp2);
            }else{
                if(i == index){
                    strbu.append(end);
                }else{
                    strbu.append(num%10);
                }
            }
        }

        strbu.reverse() ;
        while(strbu.charAt(0) == '0'){
            strbu.delete(0,1);
        }
        return strbu.toString() ;
    }
}

